package com.ekang.admin.web;

import com.ekang.admin.common.BaseResult;
import com.ekang.admin.model.User;
import com.ekang.admin.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by zcz on 2017/10/25.
 */
@Controller
public class UserController {


    @Autowired
    UserService userService;

    @RequestMapping("/user")
    @ResponseBody
    public ResponseEntity<BaseResult> getUser(@RequestParam("userID") Integer userID) throws Exception {
        User user = userService.getUserById(userID);
        BaseResult baseResult = new BaseResult();
        baseResult.setCode("1");
        baseResult.setData(user);
        return new ResponseEntity(baseResult, null, HttpStatus.OK);
    }


    @RequestMapping("/goods")
    @ResponseBody
    public ResponseEntity<BaseResult> getGoodsList() throws Exception {
        User user = userService.getUserById(1);
        BaseResult baseResult = new BaseResult();
        baseResult.setCode("1");
        baseResult.setData(user);
        return new ResponseEntity(baseResult, null, HttpStatus.OK);
    }
}
